#include <iostream>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <climits>
using namespace std;

typedef pair<int, int> pii;
unordered_map<int, unordered_map<int, int>> show;
unordered_map<int, unordered_map<int, char>> map_data;
int ans = 0;

void update(int x1, int y1) {
    vector<pii> directions = {
        {0, -1}, {0, 1}, {-1, 0}, {-1, 1}, {-1, -1},
        {1, 0}, {1, 1}, {1, -1}
    };
    
    for (auto& dir : directions) {
        int nx = x1 + dir.first;
        int ny = y1 + dir.second;
        
        if (map_data[nx][ny] != '*') {
            show[nx][ny]++;
            ans = max(ans, show[nx][ny]);
        }
    }
}

int main() {
    int n;
    cin >> n;
    vector<pii> points;
    
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        points.push_back({x, y});
        map_data[x][y] = '*';
        show[x][y] = 0;
    }
    
    for (auto& p : points) {
        update(p.first, p.second);
    }
    
    cout << ans << endl;
    return 0;
}
